/**
 * 存储localStorage
 * @param {*} name
 * @param {*} content
 */
export const setStorage = (name, content) => {
  if (!name) return
  if (typeof content !== 'string') {
    content = JSON.stringify(content)
  }
  localStorage.setItem(name, content)
}

/**
 * 获取localStorage
 * @param {*} name
 */
export const getStorage = (name) => {
  if (!name) return
  return localStorage.getItem(name)
}

/**
 * 处理图片路径
 */
export const getImgPath = (path) => {
  //传递过来的图片地址需要处理后才能正常使用(path) {
  let suffix;
  if (!path) {
    return '//elm.cangdu.org/img/default.jpg'
  }
  if (path.indexOf('jpeg') !== -1) {
    suffix = '.jpeg'
  } else {
    suffix = '.png'
  }
  let url = '/' + path.substr(0, 1) + '/' + path.substr(1, 2) + '/' + path.substr(3) + suffix;
  return 'https://fuss10.elemecdn.com' + url
}